﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Fraction
{
    class Fraction: IFormattable
    {
        private int numerator;
        private int denumerator;

        public Fraction(int numerator,int denumerator)
        {
            this.numerator = numerator;
            this.denumerator = denumerator;
        }

        public string ToString(string format, IFormatProvider formatProvider)
        {
            if (format == "N") 
            {
                return string.Format("{0}/{1}", this.Numerator, this.Denumerator);
            }
            else if (format == "R")
            {
                return string.Format("{0:F2}", (double)this.Numerator / this.Denumerator);
            }
            else
            {
                return ((double)this.Numerator / this.Denumerator).ToString();
            }
        }

        public int Denumerator
        {
            get
            {
                return denumerator;
            }
            set
            {
                denumerator = value;
            }
        }

        public int Numerator
        {
            get
            {
                return numerator;
            }
            set
            {
                numerator = value;
            }
        }
    }
}
